package fr.sportsurbains;

import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.PreferenceActivity;
import android.view.Menu;

import com.google.android.gcm.GCMRegistrar;

public class SettingsActivity extends PreferenceActivity {
	

	CheckBoxPreference notification;
	
	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.preferences);
		//getListView().setBackgroundColor(getResources().getColor(R.color.black));
		String notif_key = getString(R.string.notif_key);
		notification = (CheckBoxPreference) findPreference(notif_key);
		if(GCMRegistrar.isRegisteredOnServer(this)) {
			notification.setEnabled(true);
		} else {
			notification.setEnabled(false);
		}
		try {
			GCMRegistrar.checkDevice(this);  
	        GCMRegistrar.checkManifest(this);
		} catch(UnsupportedOperationException uoe) {
			notification.setChecked(false);
			notification.setEnabled(false);
			notification.setSummaryOff(R.string.notif_unsupported);
		} catch(IllegalStateException ise) {
			
		}
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.settings, menu);
		return true;
	}

}
